package com.lee;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
//        Student student = new Student();
//        student.otherMethod();
//        Scanner scanner = new Scanner(System.in);
//
//        int count = scanner.nextInt();

//        login();

        traversal();
    }

    public static void login(){
        Scanner scanner = new Scanner(System.in);
        // 用循环实现多次机会，这里的次数明确，采用 for 循环实现
        for (int i = 0; i < 3; i++) {
            System.out.println("请输入用户名：");
            String username = scanner.next();
            System.out.println("请输入密码: ");
            String password = scanner.next();

            if(username.equals("admin") && password.equals("123")) {
                System.out.println("登陆成功");
                break; // 跳出循环
            } else {
                System.out.println("用户名或密码错误");
            }
        }
    }

    public static void traversal() {
        String str = new String("hello world");
        // 字符串转为字符数组
        char[] arr = str.toCharArray();
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }

    }
}
